--[[/**
-- * 
 * 造成的伤害 给自己加护盾值
 * [0] 造成伤害的buffId
 * [1] 护盾的buffId
-- *
-- */]]

---@class BuffEffect592100 : BaseBuffEffect
BuffEffect592100 = ClientFight.CreateClass("BuffEffect592100", ClientFight.BaseBuffEffect)
local t = BuffEffect592100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    local source = buff.source;
    if (table.getn(parameters) < 3)then
    return IBuffEffect.FAIL;
    end
    if (not parameters[3])then
    return IBuffEffect.FAIL;
    end
    if (not parameters[2])then
    return IBuffEffect.FAIL;
    end
    local result = parameters[3];
    if (not result:isDamage())then
    return IBuffEffect.FAIL;
    end
    if (not AttackUtils.isDamage(result.state))then
    return IBuffEffect.FAIL;
    end
    local usingSkill = parameters[2];
    local buffId =  usingSkill.parameters[FightConst.BUFF_MODEL_ID] or 0;
    local buffIdConf = buff.buffBean.f_BuffEffectValue[1];
    if (buffId ~= buffIdConf) then
    return IBuffEffect.FAIL;
    end
    local addHp = Utils.calcRatio(result.damage,buff.buffBean.f_BuffEffectValue[3]);
    if (addHp <= 0)then
    return IBuffEffect.FAIL;
    end
    local buffModelId = buff.buffBean.f_BuffEffectValue[2];--护盾的buffid
    BuffManager.addBuff(fight,buff.skill,buff.source,buff.target,false,buffModelId,1,addHp,0,0,0);

    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
    .. buff.modelId .. " 伤害转化为护盾值: "..addHp .." , 伤害量 " .. result.damage);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()